package org.lzfto.flink.demo.business.student;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.sql.Date;
import java.sql.Timestamp;

public class Student {
    private int studentId;
    private String name;
    private Gender gender;
    private LocalDate birthDate;
    private String email;
    private LocalDateTime lastOptime;

    public enum Gender {
        Male, Female
    }

    // Constructors
    public Student() {}

    public Student(int studentId, String name, Gender gender, LocalDate birthDate, String email) {
        this.studentId = studentId;
        this.name = name;
        this.gender = gender;
        this.birthDate = birthDate;
        this.email = email;
    }

    // 从数据库结果集转换
    public Student(int studentId, String name, String gender, Date birthDate, String email, Timestamp lastOptime) {
        this.studentId = studentId;
        this.name = name;
        this.gender = Gender.valueOf(gender);
        this.birthDate = birthDate != null ? birthDate.toLocalDate() : null;
        this.email = email;
        this.lastOptime = lastOptime != null ? lastOptime.toLocalDateTime() : null;
    }

    // Getters and Setters
    public int getStudentId() {
        return studentId;
    }

    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public LocalDate getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(LocalDate birthDate) {
        this.birthDate = birthDate;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public LocalDateTime getLastOptime() {
        return lastOptime;
    }

    public void setLastOptime(LocalDateTime lastOptime) {
        this.lastOptime = lastOptime;
    }

    @Override
    public String toString() {
        return "Student{" +
                "studentId=" + studentId +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", birthDate=" + birthDate +
                ", email='" + email + '\'' +
                ", lastOptime=" + lastOptime +
                '}';
    }
}
